<?php

/**
* @ignore
*/

define('IN_SMART', true);
$smt_root_path = (defined('SMT_ROOT_PATH')) ? SMT_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($smt_root_path . 'common.' . $phpEx);

// Basic parameter data
$mode	= request_var('mode', '');

if ($mode == 'login' || $mode == 'logout' || $mode == 'confirm')
{
	define('IN_LOGIN', true);
}

// Start session management
$user->session_begin();

$default = false;

// Basic "global" modes
switch ($mode)
{
	case 'login':
		if ($user->data['is_registered'])
		{
			header('Location: ' . "{$smt_root_path}index.$phpEx");
		}

		login_box(request_var('redirect', "index.$phpEx"));
	break;

	case 'logout':
		if ($user->data['user_id'] != ANONYMOUS)
		{
			$user->session_kill();
			$user->session_begin();
			$message = 'You have logged out.' ;
		}
		else
		{
			$message = 'Anonymous need not log out';
		}
		//meta_refresh(3, "{$smt_root_path}index.$phpEx");
		header('Refresh: 3; URL='. $smt_root_path . 'index.' . $phpEx);

		$message = $message . '<br /><br />Return to <a href="' . $smt_root_path . 'index.' . $phpEx . '">Index page</a>';
		echo $message;

	break;

	default:
		$default = true;
	break;
}

// We use this approach because it does not impose large code changes
if (!$default)
{
	return true;
}

// Only registered users can go beyond this point
if (!$user->data['is_registered'])
{
	login_box('', 'Login');
}


?>